//
//  EvaluateTableViewCell.m
//  EducationAdminClient
//
//  Created by xuyingwei on 16/11/8.
//  Copyright © 2016年 周佳兴. All rights reserved.
//

#import "EvaluateTableViewCell.h"
#import "Masonry.h"
#import "UIColor+CL.h"
#import "EducationAdminClient_URL.h"


#define KWIDTH ([UIScreen mainScreen].bounds.size.width) //屏幕宽度
#define KHEIGHT ([UIScreen mainScreen].bounds.size.height) //屏幕高度
#define LabelTagBegain 0xab12138
#define theLabelTag 0xace12138
#define starTag 0xae86efc51


@implementation EvaluateTableViewCell

-(instancetype)initWithReuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:UITableViewCellStyleDefault reuseIdentifier:reuseIdentifier];
    //    self.selectionStyle = UITableViewCellSelectionStyleNone;
    _isFirstCreateGoldStars = YES;
    _isFirstCreateBackgroundStars = YES;
    if (self) {
        if (_starCount == 0) {
            //测试使用
//            _starCount = arc4random() % 6+0;;
        }else{
            if (!_starCount) {
                _starCount = 0;
            }
        }
        _superView = [self createUI];
        _superView.backgroundColor = [UIColor whiteColor];
        _superView.layer.cornerRadius = 8;
        self.backgroundColor = [UIColor clearColor];
        
        [self.contentView addSubview:_superView];
        //#ifdef Main
        if([getUIStyle() isEqualToString:STYLE0]){
            [_superView mas_makeConstraints:^(MASConstraintMaker *make) {
                make.left.equalTo(self.contentView.mas_left).offset(26/2);
                make.top.equalTo(self.contentView.mas_top).offset(26/2);
                make.right.equalTo(self.contentView.mas_right).offset(-26/2);
                make.bottom.equalTo(self.contentView.mas_bottom);
            }];
            
        }else{
            //#elif Student
            
            [_superView mas_makeConstraints:^(MASConstraintMaker *make) {
                make.left.equalTo(self.contentView.mas_left).offset(20/2);
                make.top.equalTo(self.contentView.mas_top).offset(36/2);
                make.right.equalTo(self.contentView.mas_right).offset(-26/2);
                make.bottom.equalTo(self.contentView.mas_bottom);
            }];
        }
        //#elif Teacher
        //        //    rootview
        //        NSLog(@"老师端程序");
        //#else
        //
        //        NSLog(@"都不是");
        //#endif
            }
    return self;
}

-(UIView *)createUI{
    self.baseView = [[UIView alloc]init];
    
    
    
    

    
    
    //    UIImageView *titleImgView = [[UIImageView alloc]init];
    //    [self.baseView addSubview:titleImgView];
    
    self.titleLeftImg = [[UIImageView alloc]init];
    [self.baseView addSubview:self.titleLeftImg];
    
    self.titleLabel = [[UILabel alloc]init];
    [self.baseView addSubview:self.titleLabel];
    
    self.titleRightImg = [[UIImageView alloc]init];
    [self.baseView addSubview:self.titleRightImg];
    
    self.Label1 = [[UILabel alloc]init];
    [self.baseView addSubview:self.Label1];
    
    self.Label2 = [[UILabel alloc]init];
    [self.baseView addSubview:self.Label2];
    
    self.Label3 = [[UILabel alloc]init];
    [self.baseView addSubview:self.Label3];
    
    self.Label4 = [[UILabel alloc]init];
    [self.baseView addSubview:self.Label4];
    
    self.Label1R = [[UILabel alloc]init];
    [self.baseView addSubview:self.Label1R];
    
    self.Label2R = [[UILabel alloc]init];
    [self.baseView addSubview:self.Label2R];
    
    self.Label2R.hidden = YES;
    
    self.Label3R = [[UILabel alloc]init];
    [self.baseView addSubview:self.Label3R];
    
    self.Label4R = [[UILabel alloc]init];
    [self.baseView addSubview:self.Label4R];
    
    [self.Label1 setContentHuggingPriority:UILayoutPriorityRequired
                                   forAxis:UILayoutConstraintAxisHorizontal];//宽度够的时候优先级宽度根据label内容
    [self.Label2 setContentHuggingPriority:UILayoutPriorityRequired
                                   forAxis:UILayoutConstraintAxisHorizontal];//宽度够的时候优先级宽度根据label内容
    [self.Label3 setContentHuggingPriority:UILayoutPriorityRequired
                                   forAxis:UILayoutConstraintAxisHorizontal];//宽度够的时候优先级宽度根据label内容
    [self.Label4 setContentHuggingPriority:UILayoutPriorityRequired
                                   forAxis:UILayoutConstraintAxisHorizontal];//宽度够的时候优先级宽度根据label内容
    [self.Label1 setContentCompressionResistancePriority:UILayoutPriorityRequired
                                                 forAxis:UILayoutConstraintAxisHorizontal];
    //    [self.Label1 setContentHuggingPriority:UILayoutPriorityRequired forAxis:UILayoutConstraintAxisVertical];
    
    
    [self.Label2 setContentCompressionResistancePriority:UILayoutPriorityRequired
                                                 forAxis:UILayoutConstraintAxisHorizontal];
    //    [self.Label2 setContentHuggingPriority:UILayoutPriorityRequired forAxis:UILayoutConstraintAxisVertical];
    
    
    [self.Label3 setContentCompressionResistancePriority:UILayoutPriorityRequired
                                                 forAxis:UILayoutConstraintAxisHorizontal];
    //    [self.Label3 setContentHuggingPriority:UILayoutPriorityRequired forAxis:UILayoutConstraintAxisVertical];
    
    
    [self.Label4 setContentCompressionResistancePriority:UILayoutPriorityRequired
                                                 forAxis:UILayoutConstraintAxisHorizontal];
    //    [self.Label4 setContentHuggingPriority:UILayoutPriorityRequired forAxis:UILayoutConstraintAxisVertical];
    
    _imgLine = [[UIImageView alloc]init];
    //    [self.Label2 sizeToFit];
    [self.baseView addSubview:_imgLine];
    
    
    self.mormalBtn = [[NormalButton alloc]init];
    [self.baseView addSubview:self.mormalBtn];
    
    //    [titleImgView mas_makeConstraints:^(MASConstraintMaker *make) {
    //        make.left.equalTo(self.baseView.mas_left);
    //        make.top.equalTo(self.baseView.mas_top).offset(26/2);
    //        make.right.equalTo(self.baseView.mas_right);
    ////        make.height.equalTo(@(30));
    //    }];
    
    [self.titleLeftImg mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.baseView.mas_left);
        make.centerY.equalTo(self.titleLabel.mas_centerY);
        make.width.equalTo(@(4/2));
        make.height.equalTo(@(20));
    }];
    
    
    [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        
#pragma mark - 学员端代码处理
        //#ifdef Main
        //        make.left.equalTo(self.titleLeftImg.mas_right).offset(10);
        //#else
        make.left.equalTo(self.titleLeftImg.mas_right).offset(46/2);
        //#endif
        make.top.equalTo(self.baseView.mas_top).offset(32/2);
        //        make.width.equalTo(@(100));
        //        make.height.equalTo(@(30));
    }];
    
    [self.titleRightImg mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.right.equalTo(self.baseView.mas_right).offset(-34/2);
        make.centerY.equalTo(self.titleLabel.mas_centerY);
        make.width.equalTo(@(32/2));
        make.height.equalTo(@(32/2));
    }];
    
    [self.Label1 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.titleLabel.mas_left);
        make.top.equalTo(self.baseView.mas_top).offset((32+32+36)/2);
        make.height.equalTo(@(32/2));
        //#ifdef Main
        if([getUIStyle() isEqualToString:STYLE0]){
            //        make.width.equalTo(@(100));
        }else{
        }
        //    }
        //#endif
        //        make.height.equalTo(@(30));
    }];
    
    [self.Label2 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.Label1.mas_left);
        make.top.equalTo(self.Label1.mas_bottom).offset(32/2);
        make.height.equalTo(@(32/2));
        
    }];
    
#pragma mark - star begain
    if (_isFirstCreateBackgroundStars) {
        for (int i = 0; i < 5; i++) {
            UIImageView *iv = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"already"]];//already_press
            [self.baseView addSubview:iv];
            [iv mas_makeConstraints:^(MASConstraintMaker *make) {
                make.centerY.equalTo(_Label2.mas_centerY);
                //                        make.bottom.equalTo(_Label2.mas_bottom);
                make.left.equalTo(_Label2.mas_right).offset(42/2+i*(12+36)/2);
                make.width.equalTo(@(36/2));
            }];
            
            if (i == 0) {
                _middleStar = [[UIImageView alloc] init];
                _middleStar = iv;
            }
            
        }
        _isFirstCreateBackgroundStars = NO;
    }
    if (_isFirstCreateGoldStars) {
        for (int i = 0; i < 5; i++) {
            UIImageView *iv = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"already_press"]];//already_press
            [self.baseView addSubview:iv];
            iv.tag = starTag+i;
            [iv mas_makeConstraints:^(MASConstraintMaker *make) {
                //                        make.top.equalTo(_Label2.mas_top);
                make.centerY.equalTo(_Label2.mas_centerY);
                //                        make.bottom.equalTo(_Label2.mas_bottom);
                make.left.equalTo(_Label2.mas_right).offset(42/2+i*(12+36)/2);
                //                        make.width.equalTo(@(36/2));
            }];
        }
        _isFirstCreateGoldStars = NO;
    }
#pragma mark - star end
    
    [self.Label3 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.Label2.mas_left);
        make.top.equalTo(self.Label2.mas_bottom).offset(38/2);
        
    }];
    
    [self.Label4 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.Label3.mas_left);
        make.bottom.equalTo(self.baseView.mas_bottom).offset(-58/2);
        
    }];
    
    [self.Label1R mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.equalTo(self.Label1.mas_right).offset(42/2);
        
        make.centerY.equalTo(self.Label1.mas_centerY);
        make.right.equalTo(self.baseView.mas_right).offset(-30/2);
        
        
    }];
    
    [self.Label2R mas_makeConstraints:^(MASConstraintMaker *make) {
        //#ifdef Main
        //        make.left.equalTo(self.Label2.mas_right).offset(20);
        //        make.right.equalTo(self.titleRightImg.mas_left);
        //#else
        make.left.equalTo(self.Label2.mas_right).offset(25);
        //#endif
        
        make.centerY.equalTo(self.Label2.mas_centerY);
        make.right.equalTo(self.baseView.mas_right).offset(-30/2);
        //        make.height.equalTo(@(30));
    }];
    
    [self.Label3R mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.equalTo(self.Label3.mas_right).offset(25);
        
        make.right.equalTo(self.baseView.mas_right).offset(-30/2);
        make.centerY.equalTo(self.Label3.mas_centerY);
        
        //        make.height.equalTo(@(30));
    }];
    
    [self.Label4R mas_makeConstraints:^(MASConstraintMaker *make) {
        
//        make.left.equalTo(self.Label4.mas_right).offset(25);
//        
//        make.right.equalTo(self.baseView.mas_right).offset(-30/2);
//        make.centerY.equalTo(self.Label4.mas_centerY);
//        make.left.equalTo(self.Label3.mas_left);
//        make.bottom.equalTo(self.baseView.mas_bottom).offset(-58/2);
//        make.centerX.equalTo(_middleStar.mas_centerX);
        make.left.equalTo(_middleStar.mas_left);
        make.top.equalTo(_middleStar.mas_bottom).offset(32/2);
        
        
        //        make.height.equalTo(@(30));
    }];
    
//    [_imgLine mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.centerX.equalTo(self.baseView.mas_centerX);
//        make.top.equalTo(self.Label4.mas_bottom).offset(40/2);
//        make.left.equalTo(self.baseView.mas_left).offset(10);
//        make.right.equalTo(self.baseView.mas_right).offset(-10);
//        make.height.equalTo(@(1));
//    }];
    
    
    [self.mormalBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self.baseView.mas_centerX);
        make.top.equalTo(_imgLine.mas_bottom).offset(26/2);
        make.width.equalTo(@(654/2));
        make.height.equalTo(@(70/2));
    }];
    
    [ self.mormalBtn setBackgroundColor:[UIColor colorWithRed:95.0/255.0 green:168.0/255.0 blue:252.0/255.0 alpha:1]];
    
    self.mormalBtn.layer.cornerRadius = 5;
    self.Label1.font = [UIFont systemFontOfSize:32/2];
    self.Label1.textColor = [UIColor colorWithHex:0x4c4c4c];
    
    self.Label2.font = [UIFont systemFontOfSize:32/2];
    self.Label2.textColor = [UIColor colorWithHex:0x4c4c4c];
    
    self.Label3.font = [UIFont systemFontOfSize:28/2];
    
    
    self.Label3.hidden = YES;
    
    
    self.Label3.textColor = [UIColor colorWithRed:0xa3/255.0 green:0xa3/255.0 blue:0xa3/255.0 alpha:1];
    
    self.Label4.font = [UIFont systemFontOfSize:28/2];
    self.Label4.textColor = [UIColor colorWithRed:0xa3/255.0 green:0xa3/255.0 blue:0xa3/255.0 alpha:1];
    _Label4.hidden = YES;
    self.Label1R.font = [UIFont systemFontOfSize:28/2];
    self.Label1R.textColor = [UIColor colorWithHex:0x858585];
    
    self.Label2R.font = [UIFont systemFontOfSize:32/2];
    self.Label2R.textColor = [UIColor colorWithRed:0x5b/255.0 green:0x5b/255.0 blue:0x5b/255.0 alpha:1];
    
    self.Label3R.font = [UIFont systemFontOfSize:32/2];
    self.Label3R.textColor = [UIColor colorWithRed:0x5b/255.0 green:0x5b/255.0 blue:0x5b/255.0 alpha:1];
    
    
    self.Label3R.hidden = YES;
    
    self.Label4R.font = [UIFont systemFontOfSize:28/2];
    self.Label4R.textColor = [UIColor colorWithHex:0x858585];
    
    self.titleLabel.font = [UIFont systemFontOfSize:36/2];
    self.titleLabel.textColor = [UIColor colorWithHex:0x4c4c4c];
    
    
    //#ifdef Main
    if([getUIStyle() isEqualToString:STYLE0]){
        NSLog(@"主项目程序");
        self.titleRightImg.image = [UIImage imageNamed:@"列表详细_"];
        [self.mormalBtn setImage:[UIImage imageNamed:@"xiangguan"] forState:UIControlStateNormal];
        [self.mormalBtn setImage:[UIImage imageNamed:@"xiangguan_h"] forState:UIControlStateHighlighted];
        _titleLeftImg.backgroundColor = [UIColor colorWithRed:0x5d/255.0 green:0xa6/255.0 blue:0xff/255.0 alpha:1];
        _titleRightImg.hidden = YES;
    }else{
        //#elif Student
        
        NSLog(@"学员端程序");
        self.titleRightImg.image = [UIImage imageNamed:@"basics_into"];
        self.titleRightImg.hidden = YES;
        //    [self.mormalBtn setImage:[UIImage imageNamed:@"xiangguan"] forState:UIControlStateNormal];
        //    [self.mormalBtn setImage:[UIImage imageNamed:@"xiangguan_h"] forState:UIControlStateHighlighted];
        [self.mormalBtn setBackgroundColor:[UIColor colorWithHex:0xff9a41]];
        self.mormalBtn.layer.cornerRadius = 5;
        [self.mormalBtn setTitle:@"查看相关列表" forState:UIControlStateNormal];
        [self.mormalBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
//        _titleLeftImg.backgroundColor = [UIColor colorWithHex:0xef5152];
        _titleLeftImg.image = [UIImage imageNamed:@"red"];
    }
    //#elif Teacher
    //    //    rootview
    //    NSLog(@"老师端程序");
    //#else
    //
    //    NSLog(@"都不是");
    //#endif
    
    
    
    _imgLine.image = [UIImage imageNamed:@"line"];
    //    titleImgView.layer.cornerRadius = 8;
    
    
    
#pragma mark - svglabel
    if (!_svgLabel) {
//        _svgLabel = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"svg.svg"]];
//        [self.baseView addSubview:_svgLabel];
//        [_svgLabel mas_makeConstraints:^(MASConstraintMaker *make) {
//            make.top.equalTo(_Label2.mas_bottom).offset(32/2);
//            make.left.equalTo(_Label2.mas_left);
//            make.width.equalTo(@(200));
//            make.height.equalTo(@(30));
//            
//        }];
        
        
//        _svgLabel.text = @"aaa";
        
//        _svgLabel.backgroundColor = [UIColor grayColor];line_dedede
    }
    
#pragma mark - line线
    self.lineIv = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"line_dedede"]];
    [self.baseView addSubview:_lineIv];
    [_lineIv mas_makeConstraints:^(MASConstraintMaker *make) {
        make.height.equalTo(@(1));
        make.left.equalTo(self.baseView.mas_left).offset(10);
        make.right.equalTo(self.baseView.mas_right).offset(-10);
        make.top.equalTo(_Label4R.mas_bottom).offset(32/2);
    }];
    
    
    
#pragma mark - svglabelend
    
    
    
    
    return self.baseView;
}

-(void)setCnName:(NSMutableArray *)cnName{
    _cnName = cnName;
    
    if (_cnName.count>=2){
        _Label1.text = [NSString stringWithFormat:@"%@", [_cnName[1] valueForKey:@"fieldCnName"]];
    }else{
        _Label1.text = @"";
    }
    if (_cnName.count>=3){
        _Label2.text =[NSString stringWithFormat:@"%@",  [_cnName[2] valueForKey:@"fieldCnName"]];
    }else{
        _Label2.text =@"";
    }
    if (_cnName.count>=4){
        _Label3.text =[NSString stringWithFormat:@"%@",  [_cnName[3] valueForKey:@"fieldCnName"]];
    }else{
        _Label3.text =@"";
    }
    if (_cnName.count>=5){
        _Label4.text =[NSString stringWithFormat:@"%@",  [_cnName[4] valueForKey:@"fieldCnName"]];
    }else{
        _Label4.text =@"";
    }
    
    _titleLabel.text = @"";
    _Label1R.text = @"";
    _Label2R.text =@"";
    _Label3R.text =@"";
    _Label4R.text =@"";
    
    
    for (id IDA in _arrqqqqqqqqqq) {
        NSString *strA = [NSString stringWithFormat:@"%@", IDA];
        
        if(_cnName.count>=1){
            NSString *testStr = [NSString stringWithFormat:@"%@", [_cnName[0] valueForKey:@"fieldAliasName"]] ;
            NSLog(@"%@",testStr);
            
            if ([testStr isEqualToString:strA]) {
                _titleLabel.text = [NSString stringWithFormat:@"%@", [_dic valueForKey:strA]];
                
                
                //                NSString *dicStr =[_dic objectForKey:@"fieldAliasName"];
                NSString *lastStr = [NSString stringWithFormat:@"DIC_%@",strA];
                
                //&&![_dic valueForKey:strA]
                if([[_dic valueForKey:strA] isKindOfClass:[NSNumber class]]&&![_dic valueForKey:strA]){
                    _titleLabel.text =[NSString stringWithFormat:@"%@", [_dic objectForKey:lastStr]];
                }
                
            }
        }
        if(_cnName.count>=2){
            NSString *testStr = [NSString stringWithFormat:@"%@", [_cnName[1] valueForKey:@"fieldAliasName"]] ;
            NSLog(@"%@",testStr);
            
            if ([testStr isEqualToString:strA]) {
                _Label1R.text = [NSString stringWithFormat:@"%@", [_dic valueForKey:strA]];
                
                
                //                NSString *dicStr =[_dic objectForKey:@"fieldAliasName"];
                NSString *lastStr = [NSString stringWithFormat:@"DIC_%@",strA];
                
                //&&![_dic valueForKey:strA]
                if([[_dic valueForKey:strA] isKindOfClass:[NSNumber class]]&&![_dic valueForKey:strA]){
                    _Label1R.text =[NSString stringWithFormat:@"%@", [_dic objectForKey:lastStr]];
                }
                
            }
        }
        if(_cnName.count>=3){
            if ([[NSString stringWithFormat:@"%@", [_cnName[2] valueForKey:@"fieldAliasName"]] isEqualToString:strA]) {
                
                
                _Label2R.text = [NSString stringWithFormat:@"%@", [_dic valueForKey:strA]];
                
                
                NSString *lastStr = [NSString stringWithFormat:@"DIC_%@",strA];
                
                if([[_dic valueForKey:strA] isKindOfClass:[NSNumber class]]&&![_dic valueForKey:strA]){
                    _Label2R.text =[NSString stringWithFormat:@"%@", [_dic objectForKey:lastStr]];
                    
                    NSLog(@"%@", [_dic objectForKey:lastStr]);
                }
            }
        }
        
        if(_cnName.count>=4){
            if ([[NSString stringWithFormat:@"%@", [_cnName[3] valueForKey:@"fieldAliasName"]] isEqualToString:strA]) {
                _Label3R.text = [NSString stringWithFormat:@"%@", [_dic valueForKey:strA]];
                
                //                NSString *dicStr =[_dic objectForKey:@"fieldAliasName"];
                NSString *lastStr = [NSString stringWithFormat:@"%@",strA];
                if([[_dic valueForKey:strA] isKindOfClass:[NSNumber class]]&&![_dic valueForKey:strA]){
                    _Label3R.text =[NSString stringWithFormat:@"%@", [_dic objectForKey:lastStr]];
                }
                
            }
        }
        
        if(_cnName.count>=5){
            if ([[NSString stringWithFormat:@"%@", [_cnName[4] valueForKey:@"fieldAliasName"]] isEqualToString:strA]) {
                _Label4R.text = [NSString stringWithFormat:@"%@", [_dic valueForKey:strA]];
                
                //                NSString *dicStr =[_dic objectForKey:@"fieldAliasName"];
                NSString *lastStr = [NSString stringWithFormat:@"%@",strA];
                if([[_dic valueForKey:strA] isKindOfClass:[NSNumber class]]&&![_dic valueForKey:strA]){
                    _Label4R.text =[NSString stringWithFormat:@"%@", [_dic objectForKey:lastStr]];
                }
                
            }
        }
        
    }
    

    //    _image = [_dic objectForKey:@"AFM_1"];
    //NSString * titleStr = [NSString stringWithFormat:@"%@", [_dic objectForKey:_arrqqqqqqqqqq[0]]];
    
    
    //_titleLabel.text = titleStr;
    
    //NSLog(@"%@", _Label2R.text);
    
    
    
}

-(void)setDic:(NSDictionary *)dic andCNName:(NSMutableArray *)CNName{
    _dic = dic;
    
    NSString *realStarCountNew;
    for (NSDictionary *dics in CNName) {
        if ([[dics objectForKey:@"fieldCnName"] isEqualToString:@"星数"]) {
            realStarCountNew = [NSString stringWithFormat:@"%@",[dic objectForKey:[dics objectForKey:@"fieldAliasName"]]];
        }
    }
    NSArray *arrqqqqq = [dic allKeys];
    
    arrqqqqq = [arrqqqqq sortedArrayUsingComparator:^NSComparisonResult(id obj1, id obj2){
        NSComparisonResult result = [obj1 compare:obj2];
        return result==NSOrderedDescending;
    }];
    NSString *realStarCount = [_dic valueForKey:@"DIC_AFM_3"];
    if ([realStarCountNew isEqualToString:@"5"]) {
        _starCount = 5;
    }else if([realStarCountNew isEqualToString:@"4"]){
        _starCount = 4;
    }else if([realStarCountNew isEqualToString:@"3"]){
        _starCount = 3;
    }else if([realStarCountNew isEqualToString:@"2"]){
        _starCount = 2;
    }else if([realStarCountNew isEqualToString:@"1"]){
        _starCount = 1;
    }else{
        _starCount = 0;
    }
    
    for (int i = 0; i<_starCount; i++) {
        UIImageView *iv = [self.contentView viewWithTag:starTag+i];
        iv.hidden = NO;
    }
    for (NSInteger i = _starCount; i<5; i++) {
        UIImageView *iv = [self.contentView viewWithTag:starTag+i];
        iv.hidden = YES;
    }
    
    
    
    _arrqqqqqqqqqq = arrqqqqq;
}


- (void)setMoreEvalutions:(NSArray *)evaArray andforCount:(NSInteger )forCount{
//    self.evaArray = evaArray;
    _lineNumber = 1;
//    NSInteger forCount = arc4random() % 13+3;
//    NSInteger forCount = 13;
//    NSMutableArray *count ;
//    NSMutableArray *realEvaArr = [NSMutableArray array];
//    for (int i = 0; i < forCount; i++) {
//        NSInteger arrCount = arc4random() % evaArray.count+0;
////        [count addObject:[NSString stringWithFormat:@"%zd",arrCount]];
//        [realEvaArr addObject:[evaArray objectAtIndex:arrCount]];
//    }
    
//    realEvaArr = [NSMutableArray arrayWithArray:@[@"一般1",@"没有新意2",@"作业太多3",@"讲课速度太快4",@"就拉开圣诞节aaaaaaa福利卡世纪东方5",@"讲课难理解6",@"小米回家淡淡的7",@"小米家8",@"小米回家9",@"小米家10",@"小米11",@"小米回家12",@"就拉开圣诞节福利卡世纪东方13"]];
    
    if (evaArray.count == 1&&[[evaArray firstObject] isEqualToString:@""]) {
        NSLog(@"隐藏下划线");
        _lineIv.hidden = YES;
    }else{
        _lineIv.hidden = NO;
    }
    
    self.realEvaArray = evaArray;
    NSString *allLenth = [NSString string];
    NSString *beforeLenth = [NSString string];
    int k = 0;
    
    NSMutableArray *FrameArr = [[NSMutableArray alloc] init];
    
    for (int i = 0; i < forCount; i++) {
        allLenth = [NSString stringWithFormat:@"%@%@",allLenth,[evaArray objectAtIndex:i]];
        CGRect rect = [allLenth boundingRectWithSize:CGSizeMake(KWIDTH-20, 30) options:NSStringDrawingUsesLineFragmentOrigin|NSStringDrawingUsesFontLeading attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:20]} context:nil];
        NSInteger lenth = rect.size.width + (k+1)*(14+22)/2+50/2;
        CGFloat lineBeyond = ceil(lenth/(KWIDTH-45));
        if (lineBeyond == 2) {
            allLenth = [NSString stringWithFormat:@"%@",[evaArray objectAtIndex:i]];
            beforeLenth = [NSString stringWithFormat:@"%@",[evaArray objectAtIndex:i]];
            _lineNumber++;
            k = 0;
//            UILabel * lab = [self createASpecielLabel:[realEvaArr objectAtIndex:i]];
            CGRect rect = [allLenth boundingRectWithSize:CGSizeMake(KWIDTH-20, 30) options:NSStringDrawingUsesLineFragmentOrigin|NSStringDrawingUsesFontLeading attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:20]} context:nil];
            NSInteger lenth = rect.size.width + (k+1)*(14+22)/2+50/2;
            
//            CGRect frame = lab.frame;
//            frame.origin.x = 50/2;
//            frame.origin.y = (224+22+(_lineNumber)*(52+22))/2;
//            
//            lab.frame = frame;
            NSString *topStr = [NSString stringWithFormat:@"%ld",(224+46+44+22+(_lineNumber-1)*(52+22))/2+3];
            NSString *rightStr = [NSString stringWithFormat:@"%d",50/2];
            
            [FrameArr addObject:@[topStr,@"1"]];
//            [lab mas_updateConstraints:^(MASConstraintMaker *make) {
//                make.top.equalTo(self.baseView.mas_top).offset((224+22+(_lineNumber)*(52+22))/2);
//                make.right.equalTo(_Label2.mas_left).offset(lenth);
//            }];
        }else{
            CGRect rect;
            if (i == 0||k==0) {
                rect = CGRectMake(0, 0, 0, 0);
            }else{
                rect = [beforeLenth boundingRectWithSize:CGSizeMake(KWIDTH-20, 30) options:NSStringDrawingUsesLineFragmentOrigin|NSStringDrawingUsesFontLeading attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:20]} context:nil];
            }
//
//
//            UILabel * lab = [self createASpecielLabel:[realEvaArr objectAtIndex:i]];
//
//            CGRect frame = lab.frame;
//            frame.origin.x = 50/2+rect.size.width+k*(14+22)/2;
//            frame.origin.y = (224+22+(_lineNumber-1)*(52+22))/2;
//            
//            
//            lab.frame = frame;
            beforeLenth = [NSString stringWithFormat:@"%@%@",beforeLenth,[evaArray objectAtIndex:i]];
            NSString *topStr = [NSString stringWithFormat:@"%ld",(224+46+44+22+(_lineNumber-1)*(52+22))/2+3];
            NSString *rightStr = [NSString stringWithFormat:@"%f",50/2+rect.size.width+k*(14+22)/2];
            
            [FrameArr addObject:@[topStr,@"0"]];
//            [lab mas_updateConstraints:^(MASConstraintMaker *make) {
//                make.top.equalTo(self.baseView.mas_top).offset((224+22+(_lineNumber-1)*(52+22))/2);
//                make.right.equalTo(_Label2.mas_left).offset(lenth);
//            }];
            k++;
        }
                                  
        
    }
    for (int i = 0;i < 13 ;i++) {
        UILabel *lab = (UILabel *)[self.contentView viewWithTag:LabelTagBegain+i+1];
        [lab removeFromSuperview];

    }
    for (int i = 0; i<FrameArr.count; i++) {
        if (i == 0) {
//            if (!_lab1) {
                _lab1 = [self createASpecielLabel:[self.realEvaArray objectAtIndex:i]];
                _lab1.tag = LabelTagBegain+1;
            
            [_lab1 mas_updateConstraints:^(MASConstraintMaker *make) {
                make.top.equalTo(self.baseView.mas_top).offset([[[FrameArr objectAtIndex:i] firstObject] intValue]);
                    make.left.equalTo(self.baseView.mas_left).offset(50/2);
                
                
            }];
        }
        else if(i == 1){
//            if (!_lab2) {
                _lab2 = [self createASpecielLabel:[self.realEvaArray objectAtIndex:i]];
                _lab2.tag = LabelTagBegain+2;
//            }
            [_lab2 mas_updateConstraints:^(MASConstraintMaker *make) {
                make.top.equalTo(self.baseView.mas_top).offset([[[FrameArr objectAtIndex:i] firstObject] intValue]);
                if ([[[FrameArr objectAtIndex:i] lastObject] isEqualToString:@"0"]) {
                    make.left.equalTo(_lab1.mas_right).offset(34/2);
                }else{
                    make.left.equalTo(self.baseView.mas_left).offset(50/2);
                }
            }];
        }
        else if(i == 2){
//            if (!_lab3) {
                _lab3 = [self createASpecielLabel:[self.realEvaArray objectAtIndex:i]];
                _lab3.tag = LabelTagBegain+3;
//            }
            [_lab3 mas_updateConstraints:^(MASConstraintMaker *make) {
                make.top.equalTo(self.baseView.mas_top).offset([[[FrameArr objectAtIndex:i] firstObject] intValue]);
                if ([[[FrameArr objectAtIndex:i] lastObject] isEqualToString:@"0"]) {
                    make.left.equalTo(_lab2.mas_right).offset(34/2);
                }else{
                    make.left.equalTo(self.baseView.mas_left).offset(50/2);
                }
            }];
        }
        else if(i == 3){
//            if (!_lab4) {
                _lab4 = [self createASpecielLabel:[self.realEvaArray objectAtIndex:i]];
                _lab4.tag = LabelTagBegain+4;
//            }
            [_lab4 mas_updateConstraints:^(MASConstraintMaker *make) {
                make.top.equalTo(self.baseView.mas_top).offset([[[FrameArr objectAtIndex:i] firstObject] intValue]);
                if ([[[FrameArr objectAtIndex:i] lastObject] isEqualToString:@"0"]) {
                    make.left.equalTo(_lab3.mas_right).offset(34/2);
                }else{
                    make.left.equalTo(self.baseView.mas_left).offset(50/2);
                }
            }];
        }
        else if(i == 4){
//            if (!_lab5) {
                _lab5 = [self createASpecielLabel:[self.realEvaArray objectAtIndex:i]];
                _lab5.tag = LabelTagBegain+5;
//            }
            [_lab5 mas_updateConstraints:^(MASConstraintMaker *make) {
                make.top.equalTo(self.baseView.mas_top).offset([[[FrameArr objectAtIndex:i] firstObject] intValue]);
                if ([[[FrameArr objectAtIndex:i] lastObject] isEqualToString:@"0"]) {
                    make.left.equalTo(_lab4.mas_right).offset(34/2);
                }else{
                    make.left.equalTo(self.baseView.mas_left).offset(50/2);
                }
            }];
        }
        else if(i == 5){
//            if (!_lab6) {
                _lab6 = [self createASpecielLabel:[self.realEvaArray objectAtIndex:i]];
                _lab6.tag = LabelTagBegain+6;
//            }
            [_lab6 mas_updateConstraints:^(MASConstraintMaker *make) {
                make.top.equalTo(self.baseView.mas_top).offset([[[FrameArr objectAtIndex:i] firstObject] intValue]);
                if ([[[FrameArr objectAtIndex:i] lastObject] isEqualToString:@"0"]) {
                    make.left.equalTo(_lab5.mas_right).offset(34/2);
                }else{
                    make.left.equalTo(self.baseView.mas_left).offset(50/2);
                }
            }];
        }
        else if(i == 6){
//            if (!_lab7) {
                _lab7 = [self createASpecielLabel:[self.realEvaArray objectAtIndex:i]];
                _lab7.tag = LabelTagBegain+7;
//            }
            [_lab7 mas_updateConstraints:^(MASConstraintMaker *make) {
                make.top.equalTo(self.baseView.mas_top).offset([[[FrameArr objectAtIndex:i] firstObject] intValue]);
                if ([[[FrameArr objectAtIndex:i] lastObject] isEqualToString:@"0"]) {
                    make.left.equalTo(_lab6.mas_right).offset(34/2);
                }else{
                    make.left.equalTo(self.baseView.mas_left).offset(50/2);
                }
            }];
        }
        else if(i == 7){
//            if (!_lab8) {
                _lab8 = [self createASpecielLabel:[self.realEvaArray objectAtIndex:i]];
                _lab8.tag = LabelTagBegain+8;
//            }
            [_lab8 mas_updateConstraints:^(MASConstraintMaker *make) {
                make.top.equalTo(self.baseView.mas_top).offset([[[FrameArr objectAtIndex:i] firstObject] intValue]);
                if ([[[FrameArr objectAtIndex:i] lastObject] isEqualToString:@"0"]) {
                    make.left.equalTo(_lab7.mas_right).offset(34/2);
                }else{
                    make.left.equalTo(self.baseView.mas_left).offset(50/2);
                }
            }];
        }
        else if(i == 8){
//            if (!_lab9) {
                _lab9 = [self createASpecielLabel:[self.realEvaArray objectAtIndex:i]];
                _lab9.tag = LabelTagBegain+9;
//            }
            [_lab9 mas_updateConstraints:^(MASConstraintMaker *make) {
                make.top.equalTo(self.baseView.mas_top).offset([[[FrameArr objectAtIndex:i] firstObject] intValue]);
                if ([[[FrameArr objectAtIndex:i] lastObject] isEqualToString:@"0"]) {
                    make.left.equalTo(_lab8.mas_right).offset(34/2);
                }else{
                    make.left.equalTo(self.baseView.mas_left).offset(50/2);
                }
            }];
        }
        else if(i == 9){
//            if (!_lab10) {
                _lab10 = [self createASpecielLabel:[self.realEvaArray objectAtIndex:i]];
                _lab10.tag = LabelTagBegain+10;
//            }
            [_lab10 mas_updateConstraints:^(MASConstraintMaker *make) {
                make.top.equalTo(self.baseView.mas_top).offset([[[FrameArr objectAtIndex:i] firstObject] intValue]);
                if ([[[FrameArr objectAtIndex:i] lastObject] isEqualToString:@"0"]) {
                    make.left.equalTo(_lab9.mas_right).offset(34/2);
                }else{
                    make.left.equalTo(self.baseView.mas_left).offset(50/2);
                }
            }];
        }
        else if(i == 10){
//            if (!_lab11) {
                _lab11 = [self createASpecielLabel:[self.realEvaArray objectAtIndex:i]];
                _lab11.tag = LabelTagBegain+11;
//            }
            [_lab11 mas_updateConstraints:^(MASConstraintMaker *make) {
                make.top.equalTo(self.baseView.mas_top).offset([[[FrameArr objectAtIndex:i] firstObject] intValue]);
                if ([[[FrameArr objectAtIndex:i] lastObject] isEqualToString:@"0"]) {
                    make.left.equalTo(_lab10.mas_right).offset(34/2);
                }else{
                    make.left.equalTo(self.baseView.mas_left).offset(50/2);
                }
            }];
        }
        else if(i == 11){
//            if (!_lab12) {
                _lab12 = [self createASpecielLabel:[self.realEvaArray objectAtIndex:i]];
                _lab12.tag = LabelTagBegain+12;
//            }
            [_lab12 mas_updateConstraints:^(MASConstraintMaker *make) {
                make.top.equalTo(self.baseView.mas_top).offset([[[FrameArr objectAtIndex:i] firstObject] intValue]);
                if ([[[FrameArr objectAtIndex:i] lastObject] isEqualToString:@"0"]) {
                    make.left.equalTo(_lab11.mas_right).offset(34/2);
                }else{
                    make.left.equalTo(self.baseView.mas_left).offset(50/2);
                }
            }];
        }
        else if(i == 12){
//            if (!_lab13) {
                _lab13 = [self createASpecielLabel:[self.realEvaArray objectAtIndex:i]];
                _lab13.tag = LabelTagBegain+13;
//            }
            [_lab13 mas_updateConstraints:^(MASConstraintMaker *make) {
                make.top.equalTo(self.baseView.mas_top).offset([[[FrameArr objectAtIndex:i] firstObject] intValue]);
                if ([[[FrameArr objectAtIndex:i] lastObject] isEqualToString:@"0"]) {
                    make.left.equalTo(_lab12.mas_right).offset(34/2);
                }else{
                    make.left.equalTo(self.baseView.mas_left).offset(50/2);
                }
            }];
        }
    
    
    }
    
    [self hiddenLabels:evaArray.count];
    NSLog(@"%zd",_lineNumber);
    
    
//    NSLog(@"%@",allLenth);
////    NSInteger arrCount = arc4random() % evaArray.count+0;
////    NSString *name = [evaArray objectAtIndex:arrCount];
//    CGRect rect = [allLenth boundingRectWithSize:CGSizeMake(KWIDTH-20, 30) options:NSStringDrawingUsesLineFragmentOrigin|NSStringDrawingUsesFontLeading attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:20]} context:nil];
//    
//    NSInteger lenth = rect.size.width+forCount*20;
//    NSLog(@"%zd",lenth);
//    CGFloat lineNumber = ceil(lenth/KWIDTH);
//    NSLog(@"%f",lineNumber);
//    
//    for (int i = 0; i < forCount; i++) {
//        
//    }
    
    
    
}


- (void)hiddenLabels:(NSInteger )count{
    for (NSInteger i = count; i < 13; i++) {
        UILabel *lab = (UILabel *)[self.contentView viewWithTag:LabelTagBegain+i+1];
        if (lab) {
            lab.hidden = YES;
        }
        
    }
    for (int i = 0; i < count; i++) {
        UILabel *lab = (UILabel *)[self.contentView viewWithTag:LabelTagBegain+i+1];
        if (lab) {
            lab.hidden = NO;
            UILabel * label = (UILabel *)[lab viewWithTag:theLabelTag];
            label.text = [self.realEvaArray objectAtIndex:i];
        }
    }
}

- (UILabel *)createASpecielLabel:(NSString *)title{
    if ([title isEqualToString:@""]) {
        return nil;
    }
    UILabel *bgLabel = [[UILabel alloc] init];
    [self.baseView addSubview:bgLabel];
    UILabel *titleLabel = [[UILabel alloc] init];
    [bgLabel addSubview:titleLabel];
    titleLabel.text = title;
    titleLabel.textColor = [UIColor colorWithHex:0xff8a18];
    titleLabel.font = [UIFont systemFontOfSize:32/2];
    [titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(bgLabel.mas_top).offset(10/2);
        make.bottom.equalTo(bgLabel.mas_bottom).offset(-10/2);
        make.left.equalTo(bgLabel.mas_left).offset(14/2);
        make.height.equalTo(@(32/2));
        make.right.equalTo(bgLabel.mas_right).offset(-22/2);
    }];
    titleLabel.tag = theLabelTag;
    bgLabel.layer.cornerRadius = 3.0f;
    bgLabel.layer.borderWidth = 3/2;
    bgLabel.layer.borderColor = [UIColor colorWithHex:0xff8a18].CGColor;
    bgLabel.backgroundColor = [UIColor clearColor];
    
    return bgLabel;
}




- (void)setSuperViewRect:(NSIndexPath *)indexPath{
    if (indexPath.row == 0) {
        [_superView mas_updateConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self.contentView.mas_top).offset(28/2);
        }];
    }else{
        [_superView mas_updateConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self.contentView.mas_top).offset(36/2);
        }];
    }
}

/*
 // Only override drawRect: if you perform custom drawing.
 // An empty implementation adversely affects performance during animation.
 - (void)drawRect:(CGRect)rect {
 // Drawing code
 }
 */

@end
